home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / builderExamples / stopwatch / Control.c++ next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.0 KB  |  144 lines

  1. /////////////////////////////////////////////////////////////
  2. //
  3. // Source file for Control
  4. //
  5. //    This file generated by a BuilderXcessory.  DO NOT EDIT THIS FILE.
  6. //    TO ADD EXTENSIONS TO THIS CLASS, USE THE BUILDER XCESSORY
  7. //    TO CREATE A SUBCLASS.
  8. //
  9. //    This class is a user interface "component", as described
  10. //    in "Object-Oriented Programming with C++ and OSF/Motif",
  11. //    by Douglas Young, Prentice Hall, 1992. ISBN 0-13-630252-1
  12. //
  13. //
  14. /////////////////////////////////////////////////////////////
  15.  
  16.  
  17. #include "Control.h" // Generated header file for this class
  18. #include <Xm/PushB.h> 
  19. #include <Xm/RowColumn.h> 
  20. #ifndef XmNrow    
  21. #define XmNrow "row"
  22. #endif    
  23. #ifndef XmNcolumn    
  24. #define XmNcolumn "column"
  25. #endif     
  26.  
  27.  
  28.  
  29.  
  30.  
  31. // These are default resources for widgets in objects of this class
  32. // All resources will be prepended by *<name> at instantiation,
  33. // where <name> is the name of the specific instance, as well as the
  34. // name of the baseWidget. These are only defaults, and may be overriden
  35. // in a resource file by providing a more specific resource name
  36.  
  37. String  Control::_defaultControlResources[] = {
  38.         NULL
  39. };
  40.  
  41. Control::Control(const char *name, Widget parent) : 
  42.          VkComponent(name) 
  43.     Arg      args[2];
  44.     Cardinal count;
  45.  
  46.     count = 0;
  47.  
  48.     // Load any class-defaulted resources for this object
  49.  
  50.     setDefaultResources(parent, _defaultControlResources  );
  51.  
  52.  
  53.  
  54.     // Create an unmanaged widget as the top of the widget hierarchy
  55.  
  56.     _baseWidget = _control= XtVaCreateWidget ( _name,
  57.                                         xmRowColumnWidgetClass,
  58.                                         parent, 
  59.                                             XmNorientation, XmHORIZONTAL, 
  60.                                             XmNpacking, XmPACK_COLUMN, 
  61.                                         NULL); 
  62.  
  63.     // install a callback to guard against unexpected widget destruction
  64.  
  65.     installDestroyHandler();
  66.  
  67.  
  68.     // Create widgets used in this component
  69.     // All variables are data members of this class
  70.  
  71.     _startButton = XtVaCreateManagedWidget  ( "startButton",
  72.                                             xmPushButtonWidgetClass,
  73.                                             _w, 
  74.                                             XmNx, 3, 
  75.                                             XmNy, 3, 
  76.                                             XmNwidth, 49, 
  77.                                             XmNheight, 30, 
  78.                                             NULL); 
  79.  
  80.     XtAddCallback ( _startButton,
  81.                     XmNactivateCallback,
  82.                     &Control::startCallback,
  83.                     (XtPointer) this ); 
  84.  
  85.  
  86.     _stopButton = XtVaCreateManagedWidget  ( "stopButton",
  87.                                             xmPushButtonWidgetClass,
  88.                                             _w, 
  89.                                             XmNx, 55, 
  90.                                             XmNy, 3, 
  91.                                             XmNwidth, 49, 
  92.                                             XmNheight, 30, 
  93.                                             NULL); 
  94.  
  95.     XtAddCallback ( _stopButton,
  96.                     XmNactivateCallback,
  97.                     &Control::stopCallback,
  98.                     (XtPointer) this ); 
  99.  
  100.  
  101. }
  102.  
  103. Control::~Control() 
  104. {
  105.     // Empty Destructor. Base class destroys widgets
  106. }
  107.  
  108. const char * Control::className() // classname
  109. {
  110.     return ("Control");
  111. }
  112.  
  113. void Control::startCallback (Widget w, XtPointer clientData, XtPointer callData) 
  114.     Control* obj = (Control *) clientData;
  115.  
  116.     obj->start(w, callData);
  117. }
  118.  
  119. void Control::stopCallback (Widget w, XtPointer clientData, XtPointer callData) 
  120.     Control* obj = (Control *) clientData;
  121.  
  122.     obj->stop(w, callData);
  123. }
  124.  
  125.  
  126.  
  127. void Control::start(Widget, XtPointer) 
  128. {
  129.     // Empty virtual function. Called from startCallback.
  130.     // Derived classes can override.
  131. }
  132.  
  133. void Control::stop(Widget, XtPointer) 
  134. {
  135.     // Empty virtual function. Called from stopCallback.
  136.     // Derived classes can override.
  137. }
  138.  
  139.  
  140.  
  141.